package huoye.shops.guidance;

import android.support.annotation.Nullable;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import android.support.v4.view.ViewPager.OnPageChangeListener;

import java.util.ArrayList;
import java.util.List;

import huoye.shops.MainActivity;
import huoye.shops.R;
import huoye.shops.base.BaseActivity;
import huoye.shops.guidance.adapter.GuidePagerAdapter;
import huoye.shops.guidance.guide.GuideView;
import huoye.shops.guidance.guide.GuideView1;
import huoye.shops.guidance.guide.GuideView2;
import huoye.shops.guidance.guide.GuideView3;
import huoye.shops.guidance.widget.PreviewIndicator;
import huoye.shops.huoye.user.activity.SelectCityActivity;
import huoye.shops.huoye.user.activity.SelectNewActivity;


public class GuideActivity extends BaseActivity implements View.OnClickListener,OnPageChangeListener, GuideView3.OnJumpToMainListener {


    private PreviewIndicator indicator;



    private GuidePagerAdapter mAdapter;

    private GuideView[] items;
    private GuideView2 itemView2;
    private GuideView1 itemView1;
    private GuideView3 itemView3;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_guide;
    }
    private ViewPager mViewPager;
    @Override
    protected void initView(@Nullable Bundle bundle) {
        //将屏幕设置为全屏
        //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        itemView1 = new GuideView1(this);
        itemView2 = new GuideView2(this);
        itemView3 = new GuideView3(this);
        items = new GuideView[]{itemView1, itemView2, itemView3};
        itemView3.setOnJumpToMainListener(this);

        mViewPager = (ViewPager) findViewById(R.id.mViewPager);
        mViewPager.addOnPageChangeListener(this);

        indicator = (PreviewIndicator) findViewById(R.id.indicator);
        TextView tvJump = (TextView) findViewById(R.id.tvJump);
        tvJump.setOnClickListener(this);

        mAdapter = new GuidePagerAdapter(this, items);

        mViewPager.setAdapter(mAdapter);


    }


    @Override
    public void onPageScrolled(int i, float v, int i1) {

    }

    @Override
    public void onPageSelected(int i) {
        indicator.setSelected(i);
    }

    @Override
    public void onPageScrollStateChanged(int i) {

    }

    @Override
    public void onJumpToMain() {
        startActivity(SelectNewActivity.class);
        finish();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tvJump:
                onJumpToMain();
                break;
        }
    }
}
